﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:Gronia.WPF.Controls">

    <Style TargetType="{x:Type Button}" x:Key="WindowButtonStyle">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ButtonBase}">
                    <Border x:Name="Chrome" BorderBrush="{TemplateBinding BorderBrush}" Margin="0" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
                        <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="FontFamily" Value="Webdings"/>
        <Setter Property="FontSize" Value="13.333" />
        <Setter Property="Foreground" Value="Black" />
        <Setter Property="Margin" Value="0,2,3,0"/>
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Foreground" Value="Gray" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="{x:Type local:CustomWindow}">
        <Setter Property="WindowStyle" Value="None"/>
        <Setter Property="AllowsTransparency" Value="True"/>
        <Setter Property="MinHeight" Value="300"/>
        <Setter Property="MinWidth" Value="300"/>
        <Setter Property="Background" Value="White"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush" Value="Silver"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:CustomWindow}">
                    <Border Background="White" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
                        <Grid>
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition />
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition />
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal">
                                    <Button x:Name="PART_MinimizeButton" Style="{StaticResource WindowButtonStyle}" Content="0" />
                                    <Button x:Name="PART_RestoreButton" Style="{StaticResource WindowButtonStyle}" Content="1" />
                                    <Button x:Name="PART_CloseButton" Style="{StaticResource WindowButtonStyle}" Content="r" />
                                </StackPanel>
                                <Thumb x:Name="PART_DragThumb" Opacity="0" Grid.Row="0" Grid.Column="0"/>
                                <TextBlock x:Name="PART_Title" IsHitTestVisible="False" Grid.Row="0" Grid.Column="0" Text="{TemplateBinding Title}"/>
                                <Grid Background="{TemplateBinding Background}" Grid.Row="1" Grid.ColumnSpan="2" Margin="5,5,5,5">
                                    <local:BusyIndicator x:Name="PART_BusyIndicator" IsBusy="{TemplateBinding IsBusy}">
                                        <AdornerDecorator>
                                            <ContentPresenter/>
                                        </AdornerDecorator>
                                    </local:BusyIndicator>
                                </Grid>
                            </Grid>
                            <Grid x:Name="PART_ResizeGrid">
                                <Thumb Cursor="SizeNS" Opacity="0" VerticalAlignment="Top" Height="5" x:Name="PART_ResizeTop" Margin="5,0,5,0" />
                                <Thumb Cursor="SizeNS" Opacity="0" x:Name="PART_ResizeBottom" Height="5" VerticalAlignment="Bottom" Margin="5,0,5,0" />
                                <Thumb Cursor="SizeWE" Opacity="0" HorizontalAlignment="Left" Margin="0,5,0,5" Width="5" x:Name="PART_ResizeLeft"/>
                                <Thumb Cursor="SizeWE" Opacity="0" Margin="0,5,0,5" Width="5" HorizontalAlignment="Right" x:Name="PART_ResizeRight" />
                                <Thumb Cursor="SizeNESW" Opacity="0" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="5" Height="5" x:Name="PART_ResizeBottomLeft" />
                                <Thumb Cursor="SizeNWSE" Opacity="0" VerticalAlignment="Bottom" Height="5" Width="5" HorizontalAlignment="Right" x:Name="PART_ResizeBottomRight" />
                                <Thumb Cursor="SizeNESW" Opacity="0" HorizontalAlignment="Right" Width="5" Height="5" VerticalAlignment="Top" x:Name="PART_ResizeTopRight" />
                                <Thumb Cursor="SizeNWSE" Opacity="0" HorizontalAlignment="Left" Width="6" VerticalAlignment="Top" Height="5" x:Name="PART_ResizeTopLeft" />
                            </Grid>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="WindowState" Value="Maximized">
                            <Setter TargetName="PART_ResizeGrid" Property="IsHitTestVisible" Value="False"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>